<!-- 通知公告 item -->
<template>
	<view>
		<block v-for="(item, index) in listData" :key="index">
			<view class="main-box-item" @click="clickItem(item)">
				<view class="box-image">
					<image :src="item.imageUrl || '/static/default-notice.png'" mode="aspectFill"></image>
				</view>
				<view class="box-info">
					<view class="box-info-top">
						{{item.title}}
					</view>
					<view class="box-info-bottom">
						<!-- <view class="text">
							{{item.creator}}
						</view> -->
						<view class="text right">
							<!-- 发布于 -->
							<uni-dateformat :date="item.createTime" format="yyyy-MM-dd hh:mm"></uni-dateformat>
						</view>
					</view>
				</view>
			</view>
		</block>
	</view>
</template>

<script>
	export default {
		props: ['list'], //数据数组

		data() {
			return {
				listData: this.list,
			}
		},
		mounted() {},
		methods: {
			clickItem(item) {
				this.$emit('clickItem', item)
			},
		},
		filters: {},
		watch: {
			list: {
				handler(item, index) { //监听到数据变化执行方法 
					this.listData = item;
				},
				deep: true // 深度监听父组件传过来对象变化 
			}
		}
	}
</script>

<style lang='scss' scoped>
	.main-box-item {
		display: flex;
		align-items: center;
		width: calc(100% - 20px);
		height: 100px;
		background: #FFFFFF;
		vertical-align: middle;
		margin: 0px 10px;
		border-bottom-color: #E6E6E6;
		border-bottom-style: solid;
		border-bottom-width: 0.5px;

		.box-image {
			width: 80px;
			height: 80px;
			margin: 10px;
			border-radius: 8px;
			overflow: hidden;
			
			image {
				width: 100%;
				height: 100%;
			}
		}

		.box-info {
			flex: 1;
			padding: 5px;

			.box-info-top {
				max-height: 50px;
				font-size: 15px;
				overflow: hidden;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 2;
				.state-img {
					width: 18px;
					height: 18px;
					margin-right: 10px;
				}
			}

			.box-info-bottom {
				display: flex;
				margin-top: 15px;
				float: right;
				.text {
					display: flex;
					align-items: center;
					font-size: 12px;
					font-weight: 400;
					line-height: 20px;
					color: #888888;
					margin: 1px 0;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
				}

				.right {
					margin: 1px 10px;
				}
			}
		}
	}
</style>
